package main.java.indi.zyj.sword;

public class InventoryManagement {

    public int inventoryManagement(int[] stock) {
        int ans = stock[0];
        int fenshu = 1;
        for (int i = 1 ; i < stock.length ; i++) {
            if (stock[i] == ans) {
                fenshu++;
            } else {
                fenshu--;
            }
            if (fenshu == 0) {
                ans = stock[i];
                fenshu++;
            }
        }
        return ans;
    }

}
